﻿using System;

namespace Bricks.ExceptionHandling
{
    
    /// <summary>
    /// 
    /// </summary>
    public interface IExceptionHandlerFacade
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="exceptionToHandle"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        bool Handle(Exception exceptionToHandle, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="exceptionToHandle"></param>
        /// <param name="key"></param>
        /// <param name="exceptionToThrow"></param>
        /// <returns></returns>
        bool Handle(Exception exceptionToHandle, string key, out Exception exceptionToThrow);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="action"></param>
        /// <param name="key"></param>
        void Process(Action action, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="action"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        TResult Process<TResult>(Func<TResult> action, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="action"></param>
        /// <param name="defaultResult"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        TResult Process<TResult>(Func<TResult> action, TResult defaultResult, string key);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="THandler"></typeparam>
    public interface IExceptionHandlerFacade<THandler> : IExceptionHandlerFacade, IFacade<THandler>
    {
    }
}
